package com.lcm.weam.service.sys.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.lcm.weam.dao.sys.RoleMapper;
import com.lcm.weam.entity.sys.Role;
import com.lcm.weam.service.sys.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class RoleServiceImpl implements RoleService {

    @Autowired
    private RoleMapper roleMapper;

    public void addRole(Role role) {
        roleMapper.insert(role);
    }

    public void updateRole(Role role, Integer rid) {
        roleMapper.update(role, new UpdateWrapper<Role>().eq("rid", rid));
    }

    public List<Role> selectAllRole() {
        return roleMapper.selectAllRoleAndPermission();
    }

    public Role selectRoleById(Integer rid) {
        return roleMapper.selectByRid(rid);
    }

    public void deleteRole(Integer rid) {
        roleMapper.delete(new QueryWrapper<Role>().eq("rid",rid));
    }
}
